Duel and Sweep Algorithm for Order-Preserving Pattern Matching
نویسندگان
چکیده
Given a text T and a pattern P over alphabet Σ, the classic exact matching problem searches for all occurrences of pattern P in text T . Unlike exact matching problem, order-preserving pattern matching (OPPM) considers the relative order of elements, rather than their real values. In this paper, we propose an efficient algorithm for OPPM problem using the “duel-and-sweep” paradigm. Our algorithm runs in O(n+m logm) time in general and O(n + m) time under an assumption that the characters in a string can be sorted in linear time with respect to the string size. We also perform experiments and show that our algorithm is faster that KMP-based algorithm. Last, we introduce the two-dimensional order preserved pattern matching and give a duel and sweep algorithm that runs in O(n) time for duel stage and O(nm) time for sweeping time with O(m) preprocessing time.
منابع مشابه
Order-preserving matching
We introduce a new string matching problem called order-preserving matching on numeric strings where a pattern matches a text if the text contains a substring whose relative orders coincide with those of the pattern. Order-preserving matching is applicable to many scenarios such as stock price analysis and musical melody matching in which the order relations should be matched instead of the str...
متن کاملA Simple ( but Optimal ) 2 D -
The duel paradigm appeared in the recent years as crucial to design eecient 1D or 2D pattern matching algorithms. It relies on the computation of witnesses, i.e. mismatching positions between two overlapping copies of a pattern p searched in a text t. Although this is easily done in linear time in 1D, the two previous algorithms in 2D rely on quite intricate data structures. We prove new struct...
متن کاملOrder-Preserving Suffix Trees and Their Algorithmic Applications
Recently Kubica et al. (Inf. Process. Let., 2013) and Kim et al. (submitted to Theor. Comp. Sci.) introduced order-preserving pattern matching. In this problem we are looking for consecutive substrings of the text that have the same “shape” as a given pattern. These results include a linear-time order-preserving pattern matching algorithm for polynomially-bounded alphabet and an extension of th...
متن کاملOrder-Preserving Pattern Matching with k Mismatches
We study a generalization of the order-preserving pattern matching recently introduced by Kubica et al. (Inf. Process. Let., 2013) and Kim et al. (submitted to Theor. Comp. Sci.), where instead of looking for an exact copy of the pattern, we only require that the relative order between the elements is the same. In our variant, we additionally allow up to k mismatches between the pattern of leng...
متن کاملAn employee transporting problem
An employee transporting problem is described and a set partitioning model is developed. An investigation of the model leads to a knapsack problem as a surrogate problem. Finding a partition corresponding to the knapsack problem provides a solution to the problem. An exact algorithm is proposed to obtain a partition (subset-vehicle combination) corresponding to the knapsack solution. It require...
متن کامل